package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.guesstv.lib.module.bean.GuessOption;

import org.jetbrains.annotations.NotNull;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;

public class OptionAdapter extends StkProviderMultiAdapter<GuessOption> {

    public OptionAdapter(int spanCount) {
        super(spanCount);
        addItemProvider(new OptionItemProvider());
    }

    class OptionItemProvider extends BaseItemProvider<GuessOption> {

        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_option;
        }

        @Override
        public void convert(@NotNull BaseViewHolder holder, GuessOption guessOption) {
            TextView tvOption = holder.getView(R.id.tvOption);
            tvOption.setText(guessOption.content);
            if (guessOption.isSelected()) {
                tvOption.setTextColor(Color.parseColor("#72674D"));
                tvOption.setBackgroundColor(Color.parseColor("#322D22"));
            } else {
                tvOption.setTextColor(Color.parseColor("#271F0C"));
                tvOption.setBackgroundColor(Color.parseColor("#FFC84D"));
            }
        }
    }
}
